Skip to content

SMOODEV-2513: Add connect timeout to Go fetch SDK (parity with Rust #88)#89

Open
brentrager wants to merge 1 commit into
mainfrom
SMOODEV-2513-connect-timeout-go
Open

SMOODEV-2513: Add connect timeout to Go fetch SDK (parity with Rust #88)#89
brentrager wants to merge 1 commit into
mainfrom
SMOODEV-2513-connect-timeout-go

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

Problem

Go parity for Rust #88 (SMOODEV-2513). Without a connect timeout, a black-holed connect — e.g. a dead pod IP still lingering in a ClusterIP's iptables (SMOODEV-2498 / SMOODEV-2481) — stalls until the whole-request timeout (~16s stalls observed in api-prime) before retry can land on a live endpoint.

Solution

  • New ConnectTimeout field + WithConnectTimeout(d time.Duration) builder method, mirroring WithTimeout.
  • When set (> 0), the SDK-constructed *http.Client uses an *http.Transport cloned from http.DefaultTransport (preserving proxy/TLS/keep-alive) whose DialContext is a net.Dialer{Timeout: connectTimeout}. Only the connection-establishment phase is bounded; slow-but-alive handlers are unaffected.

Default-OFF

Leaving it unset (0) leaves the transport untouched → behavior byte-identical to before, so existing callers are unaffected. A caller-provided *http.Client (via WithHTTPClient) is also left untouched — the connect timeout only applies to the transport this SDK constructs.

Test

Mirrors the Rust connect_timeout_tests.rs: a request to a black-hole address (http://10.255.255.1:80/) with a 500ms connect timeout fails in ~that window (verified 0.50s), well under the 10x-larger 5s whole-request timeout. Plus a default-OFF test asserting no custom transport when unset. gofmt/go vet clean, go test ./... 97 passed.

🤖 Generated with Claude Code

Bounds only the connection-establishment phase, separate from the
whole-request WithTimeout. When set (> 0), the SDK-constructed *http.Client
uses an *http.Transport cloned from the default (preserving proxy/TLS/keepalive
settings) whose dialer times out after the configured duration. A black-holed
connect — e.g. a dead pod IP still lingering in a ClusterIP's iptables
(SMOODEV-2498 / SMOODEV-2481) — then fails in ~that window and the configured
retry can land on a live endpoint, instead of stalling until the whole-request
timeout.

Default-OFF: leaving it unset (0) preserves the previous no-connect-timeout
behavior byte-for-byte. A caller-provided *http.Client (WithHTTPClient) is left
untouched — the connect timeout only applies to the transport this SDK builds.

Test mirrors the Rust connect_timeout_tests.rs: a request to a black-hole
address (10.255.255.1:80) with a short connect timeout fails in ~that window,
well under the 10x-larger whole-request timeout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: fc2acb1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant